home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / VU Libraries / Controls.lib v3.0.15 & ref / Controls.lib Reference next >
Encoding:
Text File  |  1993-09-17  |  62.7 KB  |  1,594 lines  |  [TEXT/MPS ]

  1.     Select the following 2 lines and hit the <enter> key before printing:
  2.                 Set Font Monaco; Set Size 9; Set Tabs 4; 
  3.     Set PrintOptions '-hf Monaco -hs 9 -title "Controls.lib Reference" -b -f Monaco -s 9 -ff "!NewPage"'
  4.                         
  5.                           TABLE OF CONTENTS
  6.  
  7.  
  8.                    Content                               Page 
  9.                 --------------------------------------
  10.                 Set-Up                                3
  11.                 Application Verification            4
  12.                 Macsbug    Macros                        4
  13.                 VUMark 1.0                            5
  14.                 
  15.                 Initialization Tasks
  16.                     InitControlGlobals()            6
  17.                     PrintGlobals()                    6
  18.                     
  19.                 Logging Tasks                        
  20.                     LogStr()                        7
  21.                     TargetInfo()                    7
  22.                     MatchApp()                        8
  23.  
  24.                 Keyboard Tasks
  25.                     TypeStr()                         8
  26.                     TypeList()                          9
  27.                     KeyEq()                            9
  28.                     SpecialKey()                   10
  29.  
  30.                 Control Tasks    
  31.                     SelectMenuItem()               10
  32.                     FindMenu()                       10
  33.                     SelectButton()                   11
  34.                     SelectRadioButton()               11
  35.                     SelectCheckBox()               11
  36.                     CheckYesNo()                   11
  37.  
  38.                 Window Tasks
  39.                     DialogCheck()                   12
  40.                     FindWindow()                   12                
  41.                     SelectWindow()                   12
  42.                     DragWindow()                   13
  43.                     SizeWindow()                   14
  44.                     ZoomWindow()                   15
  45.                     ScrollWindow()                   15
  46.                     GetVHScrollBars()               16
  47.                     CloseWindow()                   16
  48.      
  49.                 Mouse Tasks
  50.                     MoveRelativeToWindow()           17
  51.                     MoveMouse()                       18
  52.                     GetXYRandom()                   18
  53.                     
  54.                 File Related Tasks    
  55.                     NameOK()                       19
  56.                     OpenDoc()                       20
  57.                     SF_Navigate()                   20
  58.                     SF_Type()                       20
  59.                     ReplaceExist()                   21
  60.                     GetNewFileName()               21
  61.  
  62.  
  63. !NewPage
  64.                     TABLE OF CONTENTS (cont)
  65.  
  66.                 Content                               Page 
  67.                 --------------------------------------
  68.                 Launch Tasks
  69.                     Twitcher()                       21
  70.                     MiniLaunch()                   22
  71.                     LaunchTwitch()                   23
  72.                     PatchLaunchTwitcher()           23
  73.                     
  74.                 String Tasks
  75.                     IsSubString()                   24
  76.                     FindPos()                       24
  77.                     Substring()                       24
  78.  
  79.                 Drawing/Tool Tasks:
  80.                     DrawShapeFrame()               24
  81.                     SelToolFromWindow()               25
  82.                     SelToolFromPallette()           25
  83.                     DoDraw()                       25
  84.                     DoText()                       26
  85.  
  86.                 Misc Tasks
  87.                     PageSetup()                       27
  88.                     Printer()                       27
  89.                     IsNumber()                       27
  90.                     PtInRect()                       27
  91.                     CenterOfScreenClick()           28
  92.                     RemoveItem()                   28
  93.                     ReplaceItem()                   28
  94.                     Timer()                           28
  95.                     ETime()                           29
  96.                     DoSpecialTest()                   29
  97.                     Scrapbook()                       29
  98.                     Quit()                           30
  99.  
  100.  
  101.  
  102.  
  103.                    Copyright Apple Computer, Inc. 1985-1990
  104.                              All rights reserved
  105. !NewPage
  106.                                     Set-Up
  107.  
  108.                             Hardware Requirements:
  109.  
  110.     Virtual User requires at least two Macintosh CPUs; 1 host and 1 target  
  111.     connected by LocalTalk cabling. 
  112.  
  113.     
  114.                             Software Requirements:
  115.  
  116.     Target CPU - The target CPU must have the Agent VU init, which is included
  117.     with Virtual User, installed. To do this, place the Agent VU extension(INIT)
  118.     into the System Folder of the target machine. Before rebooting the machine, 
  119.     set the target's name by way of the Chooser (the target's name is the same as 
  120.     the user name). Under System 7.0 use the Network Setup CDEV. Each target must 
  121.     have a unique name. The target machine should be in the same state as it 
  122.     will be when the script is executed (i.e. if the script will test Microsoft 
  123.     Word™, then Microsoft Word™ should be up and running on the target machine 
  124.     before attempting to execute the script, unless you are using the
  125.     LaunchTwitch task, in which case MiniLauncher (which can be found on the
  126.     Developer CD series) should be running if under System 6.0.x, or, if under
  127.     7.0, then the alias for the application must be in place). The keyboard
  128.     repeat rate should be turned off. Do this by opening the Keyboard CDEV and
  129.     select OFF on the 'Delay Until Repeat' radio button cluster.
  130.     
  131.     Host CPU - Install the VU tool according to the instructions in the Virtual
  132.     User General Reference. 
  133.  
  134.  
  135.                             Running Your Script:
  136.                             
  137. 1)    Make sure the hardware and software configurations match those explained
  138.     above.
  139. 2)    Launch the MPW shell. 
  140. 3)    From your MPW worksheet, type the appropriate command line in the following 
  141.     format:
  142.  
  143. VU -t '*:<Target Name>' -s 'HD:Folder:<Script Name>'
  144.  
  145. where <Target Name> is the user name in the Chooser of the target machine, 
  146. and <Script Name> is the name of the script file to be executed.  
  147.  
  148. To execute the script, place the I-beam cursor in the command line and press the
  149. <Enter> key. To abort the script, type Command-Period.  Make sure that you
  150. include the 2 lines:
  151.  
  152. Libraries "Controls.lib";
  153. InitControlGlobals();
  154.  
  155. at the top of your script if it uses any of the tasks from Controls.lib library. 
  156.  
  157. NOTE: VU Recorder can be helpful in verifying that your targets are up and 
  158.       responding as expected.  Merely launch VU Recorder and click in the 
  159.       Zones list to see all available targets.
  160.  
  161.  
  162. !NewPage
  163.                             Application Verification
  164.  
  165.                                                     
  166.         I developed an application verification scheme that allows
  167.         recogniton of a crashed target.  The verification scheme uses two
  168.         library tasks: LogStr(), and MatchApp(). For details on how to 
  169.         implement application verification please read the following:
  170.  
  171.         The default setting for the errorCheck parameter of LogStr(str, 
  172.         errorCheck:=0) is 0, therefore, using the default means that
  173.         application verification is not performed.  Application verifi-
  174.         cation can be enabled by passing a 1 in for the errorCheck para-
  175.         meter, or, since LogStr() is used for all error/status reporting 
  176.         the default setting of the errorCheck parameter can be changed to
  177.         1 (so that you don't have to pass the extra parameter).  This is 
  178.         the ONLY change that you should make to the library.  
  179.         
  180.         The next thing to do is to call MatchApp(), which will match
  181.         the current application and put its title in a global (AppTitle).
  182.         When LogStr() is called with errorCheck set to 1, it will compare
  183.         the global Apptitle to the current application and abort if they
  184.         don't match. It is important to call MatchApp after switching 
  185.         applications, but before you make a call to LogStr() so Apptitle
  186.         can be updated. You must perform this when you open DAs as well, 
  187.         since the active application becomes the DA Handler.
  188.         
  189.         A new task called Quit() has been added.  Please use this to
  190.         quit an application from within a script.  This assures proper
  191.         handling of the Application Verification scheme.
  192.         
  193.  
  194.  
  195.                             Macsbug Macros
  196.                             
  197.         We have two MacsBug macros defined on the target machines:
  198.         'FirstTime' and 'EveryTime'.
  199.         
  200.         The FirstTime macro just executes a 'G;'. The EveryTime macro logs 
  201.         various bug information to a logfile when the target machine
  202.         crashes and then reboots the target so it is ready for the next 
  203.         script. This is useful if you are running several scripts against
  204.         a target(s).  Our scripts will recognize a crash and abort that 
  205.         particular target's script, if the above application verification 
  206.         scheme is implemented.  This abort is necessary when VU re-acquires 
  207.         the target after it has rebooted.  If VU acquires the target without 
  208.         aborting the interrupted script, it will continue executing the 
  209.         script where it crashed.  However, the target is now in the Finder  
  210.         and not the application that it was supposed to be running.  This 
  211.         could be detrimental.
  212.                                                             
  213.  
  214. !NewPage
  215.                 VUMark 1.0 - by NJV - Apple Computer.
  216.  
  217.     Description: VUMark is a MPW Script that will mark a file's VU tasks
  218.             by searching the requested file for the literal string "Task" at
  219.             the beginning of a line and then marking that location with the
  220.             task name (the word following the 'task' string).  Once the end
  221.             of the file is reached, the file will be saved and, if the -nc
  222.             parameter is not present, closed.
  223.  
  224.  
  225.     Usage:
  226.     
  227.     VUMark [-nc] "vuScriptName"
  228.  
  229.         -nc                -    Optional parameter - if present, VUMark will 
  230.                             not close (nc) the script after marking it.
  231.         vuScriptName    -    The name of the VU script to be marked
  232.     
  233.  
  234. Usage Examples:
  235.  
  236.         VUMark "myScript.vu"            # mark VU tasks in myScript.vu and close
  237.                                         # myScript.vu when done
  238.                                         
  239.         VUMark -nc "myScript.vu"        # mark VU tasks in myScript.vu and don't
  240.                                         # close myScript.vu when done
  241.  
  242.  
  243. To install VUMark into an MPW Menu, add the following line to your UserStartup
  244. file, and make sure that VUMark is in your MPW Scripts folder:
  245.  
  246.         AddMenu        Special     "VUMark Active" 'VUMark -nc "{Active}"'
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258. !NewPage
  259. #Initialization Tasks
  260. #########################################################################
  261. #                            InitControlGlobals()
  262. #========================================================================
  263. # Author:        NJV
  264. # Description:    Initializes all global variables used by the Controls.lib
  265. #                library.  This task should be called immediately after
  266. #                the "Libaries 'Control.lib';" line in the script.  It
  267. #                is OK to modify the values of some of the variables.  This is 
  268. #                how you customize your VU scripting environment and the way
  269. #                that your scripts will react using this library.
  270. # Parameters:    None
  271. # Returns:        Nothing
  272. # Examples:        InitControlGlobals();
  273. # Assumptions:    That you understand what the global does before resetting it. 
  274. ################################################################################
  275. # Example Call                # Example Output
  276.     InitControlGlobals();    # Initializing Globals in Controls.lib 3.0.14
  277.                             # (as well as output from PrintGlobals();)
  278.  
  279. #########################################################################
  280. #                            PrintGlobals()
  281. #========================================================================
  282. # Author:        NJV
  283. # Description:    Prints the values of all Control Globals
  284. # Parameters:    None
  285. # Returns:        Nothing
  286. # Examples:        PrintGlobals();
  287. # Assumptions:    None 
  288. #########################################################################
  289. # Example Call            # Example Output
  290.     PrintGlobals();        # All logging is enabled
  291.                         # The 'Application Verification' scheme is turned - ON
  292.                         #
  293.                         # The global 'TargetCheck' is set to output - the
  294.                         # title of the target's current 'Application'
  295.                         #
  296.                         # Integration Testing is - 'OFF'
  297.                         # The current system is - '7.0.1'
  298. !NewPage
  299. #Logging Tasks
  300. #########################################################################
  301. #                    LogStr(str, errorCheck,doTargetCheck)
  302. #========================================================================
  303. # Author:        KTA
  304. # Description:    Match the target and print it with whatever is passed
  305. #                to it in the 'str' parameter.  Set the appropriate 
  306. #                LogPriority based on the context of the string.
  307. # Parameters:    str - string to be printed
  308. #                LogPriority -    The priority of the string to be printed
  309. #                0 - No logging
  310. #                1 - Errors
  311. #                2 - Comments and Notes
  312. #                3 - Summary information
  313. #                4 - More detailed
  314. #                5 - Detailed description
  315. # Returns:        Nothing
  316. # Examples:        LogStr("It worked");
  317. #                LogStr("It worked",3);
  318. # Assumptions:        None 
  319. #########################################################################
  320. # Example Calls                        #Example Output
  321.     LogStr("Pressed ReturnKey");    #1 - Pressed ReturnKey (Target - Title:"Se30") 
  322.  
  323.     
  324. #########################################################################
  325. #                            TargetInfo(theList)
  326. #========================================================================
  327. # Author:        NJV/KTA
  328. # Description:    Match whatever is specified in global TargetInfoDescriptor
  329. #                and will return the appropriate string.
  330. # Parameters:    theList[1] - what to match for - default 'Target'
  331. #                theList[2] - Specifier of what info to return
  332. #                    If theList[1] = 'Target'then    
  333. #                        if theList[2] = 
  334. #                         1 - Return Title for target
  335. #                         2 - Returns Application running on Target
  336. # Returns:        Str
  337. # Examples:        global TargetCheck := 1;    
  338. #                global TargetCheck :={1,2};
  339. #########################################################################
  340. # Example Calls                            # Example Output
  341.     str := TargetInfo({'Target',1});    # str = "(Target - Title:"Se30")"
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353. !NewPage
  354. #########################################################################
  355. #                     MatchApp(logMe,UpdateAppTitle)
  356. #========================================================================
  357. # Author:            KTA
  358. # Description:        This routine will match the current Application and,
  359. #                    if the logMe parameter is 1, will log the current
  360. #                    application name by passing it to LogStr().  If a
  361. #                    parameter is not passed, the default behavior will
  362. #                    log the application's title.  This routine will also
  363. #                    set the global AppTitle to the application's title.
  364. #                    Output appears in the following format:
  365. #                            The current application is "Finder"
  366. # Parameters:        logMe - 1 to print the current application's title
  367. #                            0 not to print the application's title
  368. #                    UpdateAppTitle     - 1 to update the global AppTitle
  369. #                                    - 0 not to update global AppTitle
  370. # Return Value:        string holding current application's title
  371. # Examples:            MatchApp();
  372. # Assumptions:        there is an active application
  373. #########################################################################
  374. # Example Calls
  375.     MatchApp();            #Outputs the current application's title and resets the 
  376.                         #application global for verification.(Global Apptitle)
  377.                         
  378.     MatchApp(0);        #Does not output the current application's title, but 
  379.                         #will reset the application global for verification.
  380.                                         
  381.     MatchApp(0,0);        #Does not output the current application's title, and 
  382.                         #will not reset the application global for verification.
  383.                                         
  384.  
  385.  
  386.  
  387. #Keyboard Tasks
  388. #########################################################################
  389. #                                TypeStr(str)
  390. #========================================================================
  391. # Author:        KTA
  392. # Description:    This routine will type whatever is passed in as the String.
  393. # Parameters:    str - string to be typed
  394. # Returns:        Nothing
  395. #########################################################################
  396. # Example Call
  397.     TypeStr('Hello World');       # Types 'Hello World' on the target machine and
  398.                                 # will output what was typed.
  399.  
  400.  
  401.  
  402. !NewPage 
  403. #########################################################################
  404. #                        TypeList(List,Key, flag)
  405. #========================================================================
  406. # Author:            KTA
  407. # Description:        This routine will type each item in the {list} and the 
  408. #                    selected special key after each item. If flag = 0 the 
  409. #                    special key will be suppressed after the last item.
  410. # Parameters:        List -    list holding strings to type
  411. #                    Key    -    int representing key to type after the item has
  412. #                            been typed. 
  413. #                        key := 0 Nothing
  414. #                        key := 1 (ReturnKey)
  415. #                        Key := 2 (TabKey)
  416. #                        Key := 3 (EnterKey)
  417. #                        Key := 4 (UpArrowKey)
  418. #                    flag -     1 to type special key after last item in list
  419. #                            0 to disable typing of last special key
  420. # Return Value:        None
  421. # Examples:            TypeList({'A','list', 'of items'},2); To type each item 
  422. #                    and then the tabKey
  423. # Assumptions:        None 
  424. ################################################################################    
  425. # Example Calls                            # Example Output
  426.     TypeList({"Line 1","Line 2"},1);    # Types "Line 1" and <return> key
  427.                                         # and "Line 2" and stops with cursor
  428.                                         # following the "Line 2" string.
  429.  
  430.  
  431.  
  432.  
  433.  
  434. #########################################################################
  435. #                            KeyEq(Alias,Otherkey)
  436. #========================================================================
  437. # Author:        KTA
  438. # Description:    This routine will select the Keyboard Equiv <alias>
  439. # Parameters:    Alias -        string holding character to be typed with
  440. #                            command key down.
  441. #                OtherKey -    int representing special keys to hold down in
  442. #                            conjunction with the command key
  443. #                    1 - Shift key
  444. #                    2 - Option key
  445. # Returns:        None
  446. # Examples:        KeyEq("q");
  447. #########################################################################
  448. # Example Calls
  449.     keyEq('x');                # Presses the CommandKey, types  'x', 
  450.                             # releases the CommandKey.
  451.     keyEq('v');                # Presses the CommandKey, types  'v', 
  452.                             # releases the CommandKey.
  453.                             
  454.                                         
  455.                                                         
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462. !NewPage                            
  463. #########################################################################
  464. #                        SpecialKey(Key,keyName,n)
  465. #========================================================================
  466. # Author:        KTA
  467. # Description:    This routine will type whatever SpecialKey is entered
  468. #                However it will only log the name of the special character 
  469. #                if the special key name is also passed in as a String in
  470. #                the keyName parameter.
  471. # Parameters:    Key - the VU key-word for the special key to be typed
  472. #                keyName - the string name of the special key
  473. #                n - number of times to type the special key (default = 1)
  474. # Returns:        Nothing
  475. # Examples:        SpecialKey(TabKey,"TabKey");
  476. #########################################################################
  477. # Example Calls
  478.     SpecialKey(ReturnKey);                # Types the returnKey, but the output 
  479.                                         # states 'Typed some Special character'
  480.     
  481.     SpecialKey(ReturnKey,"ReturnKey");    # Types the returnKey, and the output 
  482.                                         # states 'Typed the ReturnKey'
  483.  
  484.  
  485. #Control Tasks
  486. ########################################################################
  487. #                 SelectMenuItem(menuName1, menuName2, menuName3)                    
  488. #=======================================================================
  489. # Author:           SL
  490. # Description:        Selects the menu item by its name.
  491. # Parameters:        menuName1 := Menu item to be selected.
  492. #                    menuName2 := Menu name if non-hier menu and
  493. #                                 Level 2 menu item if hier menu.
  494. #                    menuName3 := "" if non-hier menu.
  495. #                                 Menu name if hier menu.
  496. # Returns:            menuTitle - MenuItem name that selection was successful
  497. #                    0 - Couldn't select menu item
  498. # Notes:                Do not have to pass 'menuName2' or 'menuName3'
  499. #                    as a parameter.  In that case, default value, "",
  500. #                    will be used.
  501. ########################################################################
  502. # Example Calls
  503.     SelectMenuItem("Copy", "Edit");    # Selects 'Copy' from the 'Edit' menu 
  504.                                     # if it is present and enabled.
  505.         
  506.     SelectMenuItem("Geneva", "Font", "Format");    
  507.                                     # Selects hierarchical menu 'Geneva' from                                                                                             
  508.                                     # the 'Font 'SubMenu from the 'Format' menu
  509.                                     
  510. #########################################################################
  511. #                             FindMenu(theMenuItem)
  512. #=======================================================================
  513. # Author:              KTA
  514. # Description:        Returns the Menu(s) in which theMenuItem is contained.
  515. # Parameters:        theMenuItem    :=    the menuitem to be searched for.
  516. # Returns:            0    -    Can't match theMenuItem.
  517. #                    {theMenu,""}    -    for a nonHierarchical menu.
  518. #                    {theHMenuItem, theMenu}    -    if its hierarchical.
  519. # Example:            MyMenu := FindMenu('Paste');
  520. #########################################################################
  521.  
  522. !NewPage
  523. #########################################################################
  524. #                        SelectButton(ButtonName)
  525. #========================================================================
  526. # Author:        KTA
  527. # Description:    This routine will select the button named (ButtonName)
  528. # Parameters:    ButtonName - string holding name of button to select
  529. # Returns:        0 - Couldn't select button
  530. #                ButtonName - Selected button OK
  531. #########################################################################
  532. # Example Call
  533.     SelectButton('OK'); # Selects Button titled 'OK' if present and enabled.
  534.     
  535. #######################################################################
  536. #                    SelectRadioButton(RadioButtonName)
  537. #========================================================================
  538. # Author:        KTA
  539. # Description:    This routine will select RadioButton named (RadioButtonName)
  540. # Parameters:    RadioButtonName - string name of radio button to select
  541. # Returns:        0 - Couldn't select radio button
  542. #                RadioButtonName - Selected button OK
  543. #########################################################################
  544. # Example Call
  545.     SelectRadioButton('No');        # Selects radioButton titled 'No'
  546.                                     # if it is present and enabled
  547.  
  548.  
  549. #########################################################################
  550. #                        SelectCheckBox(CheckBoxName)
  551. #========================================================================
  552. # Author:        KTA
  553. # Description:    This routine will select CheckBox named (CheckBoxName)
  554. # Paramters:    CheckBoxName - string name of check box to select
  555. # Returns:        0 - Couldn't select check box
  556. #                CheckBoxName - Selected check box OK
  557. #########################################################################
  558. # Example Call
  559.     SelectCheckBox('Left');            # Selects CheckBox titled 'Left', 
  560.                                     # if it is present and enabled.    
  561.     
  562. #########################################################################
  563. #                CheckYesNo(flag, DocName)
  564. #========================================================================
  565. # Author:        SL
  566. # Description:    Checks for dialog boxes with "Yes" (or "OK") and "No"
  567. #                buttons. If they are found, clicks one of the buttons
  568. #                depending on the 'flag' parameter.
  569. # Parameters:    flag -    TRUE - Selects "Yes"  or "OK" button.
  570. #                        FALSE - Selects "No" button.
  571. #                DocName - Name that docment will be saved with.
  572. # Returns:        What is returned by SelectButton
  573. #########################################################################
  574. # Example Calls                    # Example Output
  575.     CheckYesNo();                # Matches and selects either a 'Yes' or 'OK' 
  576.                                 # button or type the returnKey.  If the 'Save As' 
  577.                                 # dialog appears it calls NameOK(); 
  578.                                 # and generates a file name
  579.     CheckYesNo(0);                # Matches and selects a 'No' button.
  580. !NewPage
  581. #Window Tasks
  582. ########################################################################
  583. #                        DialogCheck(FindStaticText,CommitButton)
  584. #=======================================================================
  585. # Author:        KTA
  586. # Description:    This routine will to match a dialog of ordinality 1,
  587. #                with StaticText - {FindStaticText}, if found it will select the 
  588. #                Button - {CommitButton}.
  589. # Parameters:    FindStaticText - StaticText string that you want to match
  590. #                CommitButton   - Button to select if the static text is found.
  591. # Returns:        1 - Found FindStaticText and selected CommitButton
  592. #                0 - Couldn't find FindStaticText
  593. ########################################################################
  594. # Example Calls                                # Example Output
  595.     DialogCheck("Operation Failed","OK");    # if the static text "Operation
  596.                                             # Failed" is found, prints:
  597.                                             # "Found Dialog: 'Operation Failed'"
  598.  
  599.  
  600.  
  601. #########################################################################
  602. #                            FindWindow(specifier)
  603. #========================================================================
  604. # Author:        DM
  605. # Description:    FindWindow will return the descriptor of the window
  606. #                specified by the parameter specifier.
  607. # Parameters:    specifier - if string, then it holds title of window
  608. #                            if integer, then it holds ordinality of window
  609. # Returns:        0 - Couldn't find the window
  610. #                1 - found the window OK
  611. #########################################################################
  612. # Example Calls    
  613.     FindWindow(1);
  614.  
  615.  
  616. ########################################################################
  617. #                        SelectWindow(specifier)
  618. #=======================================================================
  619. # Author:        NJV
  620. # Description:    This routine will select a window specified by
  621. #                ordinality or title.
  622. # Parameters:    specifier -    holds the title or ordinality of window to
  623. #                            select.
  624. # Returns:        1 - Selected window OK
  625. #                0 - Couldn't find window to select
  626. ########################################################################
  627. # Example Calls                # Example Output
  628.     SelectWindow();            #Selects window of ordinality 1
  629.     SelectWindow(2);        #Selects window of ordinality 2
  630.     SelectWindow('Sheet');    #Selects window titled 'Sheet'
  631.  
  632.  
  633.  
  634.  
  635. !NewPage
  636. #########################################################################
  637. #                DragWindow(h,v,specifier,absolutely)
  638. #========================================================================
  639. # Author:        KTA
  640. # Description:    This routine will drag the specified window
  641. #                'h' pixels horizontally (-h drags left) and 'v' pixels
  642. #                vertically (-v drags up)
  643. # Parameters:    h    - Horizontal pixel offset to drag the window
  644. #                v    - Vertical pixel offset to drag the window
  645. #                specifier - holds title or ordinality of window to drag
  646. #                absolutely -    1 if absolute drag
  647. #                            0 if relative drag
  648. # Returns:        1 - Dragged window OK
  649. #                0 - Couldn't find window to drag
  650. #########################################################################
  651. # Example Calls
  652.     DragWindow();            # Drags the first window with a grow box and a zoom
  653.                             # box to random coordinates (on current screen).
  654.                                     
  655.     DragWindow(200,100);    # Drags the first window with a grow box and a 
  656.                             # zoom box to the absolute coordinates (200,100)
  657.                             
  658.     DragWindow(100,200,2);    # Drags the window of ordinality 2 to absolute  
  659.                             # coordinates of (100, 200)
  660.     
  661.     DragWindow(100,200,'Sheet');    # Drags the window of titled 'Sheet' to  
  662.                                     # absolute coordinates of (100, 200)
  663.  
  664.     DragWindow(200,100,2,0);        # Selects and Drags window of ordinality 2,  
  665.                                     # 200 pixels horizontally and 100 pixels 
  666.                                     # vertically relative to its current
  667.                                     # location.    
  668.     
  669.     DragWindow(200,100,'Sheet',0);    # Drags window titled 'Sheet', 200 pixels 
  670.                                     # horizontally and 100 pixels vertically 
  671.                                     # relative to its current location.
  672.  
  673. !NewPage
  674. #########################################################################
  675. #                    SizeWindow(X,Y,specifier,absolutely)
  676. #========================================================================
  677. # Author:        KTA
  678. # Description:    This routine will match and resize the specified window.
  679. #                If only the X and Y parameters are passed, the default
  680. #                behavior will size the first window containing a grow
  681. #                and zoom box absolutely.  If no parameters are passed,
  682. #                then the default behavior will generate random
  683. #                coordinates on the main screen and resize the window
  684. #                to an absolute size.  If the user passes in the string
  685. #                "random" for x and y and passes 0 for the absolutely
  686. #                parameter (for a resize relative to current size),
  687. #                then checks are performed to assure that new size will
  688. #                not go off of the screen.  If it does, the values will
  689. #                be adjusted so that the largest the window can be sized
  690. #                is to the border of the screen.
  691. # Parameters:    X,Y -    the Width and Height to resize the window
  692. #                specifier -    title or ordinality of window to be sized
  693. #                absolutely -    1 if resize window absolute
  694. #                                0 if resize window relative
  695. # Returns:        1 - Resized window OK
  696. #                0 - Couldn't resize window
  697. # Examples:        SizeWindow(200,400);
  698. #########################################################################
  699. # Example Calls
  700.     SizeWindow();            # Sizes the first window with a grow box and a 
  701.                             # zoom box to random coordinates (on current screen).
  702.                                     
  703.     SizeWindow(200,100);    # Sizes the first window with a grow box and a 
  704.                             # zoom box to the absolute coordinates (200,100)
  705.                             
  706.     SizeWindow(100,200,2);    # Sizes the window of ordinality 2 to absolute 
  707.                             #  coordinates of (100, 200)
  708.     
  709.     SizeWindow(100,200,'Sheet');    # Sizes the window of titled 'Sheet' to  
  710.                                     # absolute coordinates of (100, 200)
  711.  
  712.     SizeWindow(200,100,2,0);        # Sizes window of ordinality 2, 200 pixels  
  713.                                     # vertically and 100 pixels horizontally 
  714.                                     # relative to its current location.
  715.     
  716.     SizeWindow(200,100,'Sheet',0);    # Sizes window of titled 'Sheet', 200 pixels 
  717.                                     # vertically and 100 pixels horizontally 
  718.                                     # relative to its current location.
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. !NewPage
  731. #########################################################################
  732. #                            ZoomWindow(specifier)
  733. #========================================================================
  734. # Author:        KTA
  735. # Description:    Selects the zoom box on the requested window.  If no
  736. #                parameters are passed, then the default behavior will
  737. #                zoom the first window with a zoom box.
  738. # Parameters:    specifier -    holds title or ordinality of window to zoom
  739. # Returns:        0 - Couldn't zoom the window
  740. #                1 - Zoomed the window OK
  741. #########################################################################
  742. # Example Calls
  743.     ZoomWindow();        # Zooms the first window with a Zoom Box and a GrowBox    
  744.     
  745.     ZoomWindow(2);        # Zooms Window of ordinality 2, if it has a Zoom box    
  746.  
  747.     ZoomWindow('Sheet');    # Zooms Window titled 'Sheet', if it has a Zoom box
  748.  
  749.  
  750.  
  751. ########################################################################
  752. #                            ScrollWindow(foo,x,y)
  753. #=======================================================================
  754. # Author:        KTA/NJV
  755. # Description:    This routine will scroll the specified scrollbar on
  756. #                the active window.
  757. # Parameters:    foo = 'H' - for horizontal scrollbar
  758. #                    = 'V' - for vertical scrollbar
  759. #                <x><y> = the fraction x/y
  760. # Returns:        0 - Couldn't scroll the scroll bar
  761. #                1 - Scrolled the scroll bar
  762. # Examples:        ScrollWindow('H',1,2)  will scroll the horizontal bar 1/2
  763. # Assumptions:    That the scrollbars are present. This routine collects
  764. #                only the first two scroll bars, which are assumed to be 
  765. #                the horizontal and vertical scroll bars. 
  766. #                This routine is not 100% reliable.
  767. #########################################################################
  768. # Example Calls
  769.     ScrollWindow('H', 2,3);        # Collects the scroll bars and determine which 
  770.                                 # is vertical/horizontal, then scroll 
  771.                                 # the horizontal scrollbar the fraction 2/3
  772.                                     
  773.     ScrollWindow('V', 2,3);        # Collects the scroll bars and determine which 
  774.                                 # is vertical/horizontal, then scroll 
  775.                                 # the Vertical scrollbar the fraction 2/3
  776.  
  777.  
  778. !NewPage
  779. ########################################################################
  780. #                            GetVHScrollBars()
  781. #=======================================================================
  782. # Author:            NJV
  783. # Description:        This routine will return the vertical and horizontal
  784. #                    scroll bars.
  785. # Parameters:        None
  786. # Returns:            0 - Couldn't find scroll bars
  787. #                    {vertical,horizontal} - list of vertical and horizontal
  788. #                                            scroll bars
  789. # Examples:            scrollBars := GetVHScrollBars();
  790. # Assumptions:        Top of vertical scroll bar is at a lower vertical value
  791. #                    that the horizontal (i.e. the top of vertical rect is smaller
  792. #                    than the top of the horizontal scroll bar's rect).
  793. #########################################################################
  794. # Example Calls                            # Example Output
  795.     theScrollBars := GetVHScrollBars();    # theScrollBars holds a list of the
  796.                                         # vertical and horizontal scroll bar
  797.                                         # descriptors, respectively
  798.  
  799.  
  800.  
  801.  
  802. #########################################################################
  803. #                CloseWindow(howClose, overwrite, specifier,DocName)
  804. #========================================================================
  805. # Author:        KTA/NJV/DMM
  806. # Description:    This routine will close the specified window.  If no
  807. #                parameters are passed to this routine, the default behavior
  808. #                will select the close box of the first window with a close box.
  809. # Parameters:    howClose -    0 -    tries all three ways noted below to close the
  810. #                                window (if needed)
  811. #                            1 -    tries to close window by selecting "Close" menu
  812. #                                item
  813. #                            2 -    tries to close window by typing "Close" menu
  814. #                                item's key equivalent
  815. #                            3 -    tries to close window by selecting window's
  816. #                                close box
  817. #                overwrite -    0 -    will select "No" from a save-changes dialog
  818. #                                if one appears when closing window
  819. #                            1 -    will select "Yes" to save changes
  820. #                specifier -    holds title or ordinality of window to close
  821. #                DocName -    string holding new document name - if overWrite
  822. #                            parameter is 1, then DocName will be used for
  823. #                            naming the file.
  824. # Returns:        1 - Closed window OK
  825. #                0 - Couldn't find window to close
  826. ###########################################################################
  827. # Example Calls
  828.     CloseWindow();            # Selects the close box on the first window one.
  829.                             # It also select 'Yes' to any 'Save Changes?' dialog
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836. !NewPage
  837. #########################################################################
  838. #             MoveRelativeToWindow(x, y, specifier,mouseDown,inset)
  839. #========================================================================
  840. # Author:        NJV
  841. # Description:    This routine will calculate the window's rectangle
  842. #                and add x and y input parameters to the 
  843. #                rectangle's top-left coordinate point.  It will then
  844. #                move the mouse to that location.  The window is
  845. #                specified by the specifier input parameter.  If the
  846. #                specifier parameter is not present, the default
  847. #                behavior will move relative to the frontmost window.
  848. # Parameters:    x - int representing left (x) coord 
  849. #                    or List of points.
  850. #                y - int representing top (y) coord
  851. #                specifier - holds title or ordinality of window
  852. #                            0 matches first s:document c:true g:true window
  853. #                mouseDown - 0 - don't hold mouse key down while moving
  854. #                            1 - press mouse key down - move - release
  855. #                            2 - Click after moving - no mouse down during move
  856. #                x is ptList    3 - MultiDrag (pressmouse - move - move - move - release)
  857. #                            4 - move - release
  858. #                x is ptList    5 - MultiClick (click - move - click - move - click)
  859. #                inset    -   inset from window rect for GetXYRandom
  860. # Returns:        Nothing
  861. # Examples:        MoveRelativeToWindow(12,25);
  862. # Assumptions:    Assumes there is a window on the screen 
  863. #########################################################################
  864. # Example Calls
  865.     MoveRelativeToWindow(100,200);        # Moves (100, 200) relative to the  
  866.                                         # top left corner of the front window.
  867.     
  868.     MoveRelativeToWindow(100,200,2);    # Moves (100, 200) relative to the 
  869.                                         # top left corner of window ordinality 2
  870.                                             
  871.     MoveRelativeToWindow(100,200,'Sheet');    # Moves (100, 200) relative to the
  872.                                             # top-left corner of window titled
  873.                                             # 'Sheet'
  874.  
  875. !NewPage
  876. #########################################################################
  877. #                 MoveMouse(x, y, absolutely, mouseDown)
  878. #========================================================================
  879. # Author:        DMM
  880. # Description:    This routine will move the mouse x,y relative to
  881. #                it s current location  If x and y are absent or
  882. #                equal to "random", a random move is generated.
  883. # Parameters:    absolutely - 1 if move absolutely, 0 if relative
  884. #                x         x distance to move mouse
  885. #                y         y distance to move mouse
  886. #                        if x and y are absent or := "random" then a 
  887. #                        random move is generated
  888. #                absolutely    -    1 to move to absolute location
  889. #                                0 to move relative to current location
  890. #                mouseDown - 0 - don't hold mouse key down while moving
  891. #                            1 - press mouse key down - move - release
  892. #                            2 - Click after moving - no mouse down during move
  893. #                            3 - press mouse key down - move - don't release
  894. #                x is List    3 - MultiDrag
  895. #                            4 - move - release
  896. #                x is List    5 - MultiClick
  897. # Returns:        Nothing
  898. #########################################################################
  899. # Example Calls                    # Example Output
  900.     MoveMouse();                # Moves the mouse to a random location
  901.                                 # within the current screen
  902.     
  903.     MoveMouse(100,200);            # Moves the mouse to absolute location (100,200)
  904.     
  905.     MoveMouse(100,200, 0);        # Moves the mouse (100,200) relative to 
  906.                                 # its current location
  907.     
  908.     MoveMouse(100,200, 1, 1);    # Presses the mouse button, moves the mouse to 
  909.                                 # absolute location (100,200), then releases 
  910.                                 # the mouse button.
  911.                                     
  912.     MoveMouse(100,200, 0, 1);    # Presses the mouse button, move the mouse  
  913.                                 # (100,200) relative to its current location, 
  914.                                 # then release the mouse.
  915.  
  916. ########################################################################
  917. #                        GetXYRandom(inset, specifier)
  918. #=======================================================================
  919. # Author:             SL
  920. # Description:        Returns a random X and Y coordinate in the specified
  921. #                    screen or window.
  922. # Parameters:        inset - ltrb inset from scrn or window
  923. #                    specifier > 0 window to find coords in
  924. #                              = O coords in window with s:doc g:true and c:true
  925. #                              < 0 coords in specified screen.  Screen numbersta
  926. #                                is negative of specifier.
  927. # Returns:            xyRandom - List of random X and Y.  eg. { x, y }
  928. ########################################################################
  929. # Example Calls
  930.     GetXYRandom();                    # Will return random coordinates from
  931.                                     # the first document window with grow
  932.                                     # and zoom box
  933. !NewPage
  934.  
  935.     GetXYRandom({25,25,25,25},2);    # Will return random values contained 
  936.                                     # in the second window with the values
  937.                                     # at least 25 pixels from all window
  938.                                     # borders
  939.                         
  940.     GetXYRandom({0,0,0,0},-2);        # Will return random values contained 
  941.                                     # in the second screen                        
  942.  
  943.  
  944. #########################################################################
  945. #                        NameOK(NameDoc, replaceFlag)
  946. #========================================================================
  947. # Author:        KTA
  948. # Description:    This routine will type a name (NameDoc) into the text edit
  949. #                field.  Then it will press the ReturnKey. If there is a
  950. #                document already named <NameDoc> then this task will check
  951. #                the replaceFlag.  If it is defined as anything but true
  952. #                it will select NO to 'Replace Existing?' dialog. It will
  953. #                then type the time (based on a 24 hour clock) after the
  954. #                name and retype the ReturnKey. The Default is to replace
  955. #                an existing document with the same name. It will also call
  956. #                getNewFileName to create a file name if one is not provided.
  957. # Parameters:    NameDoc - string holding the name to name the document
  958. #                replaceFlag - 0 to select 'No' to 'Replace Existing' dialog
  959. #                              1 to select 'Yes' to replace exisiting file.
  960. # Returns:        string - filename of saved document
  961. # Examples:        NameOk('Untitled1'); to name the file 'Untitled1'
  962. # Assumptions:    That the SF_Put dialog is present
  963. #                 A call to SelectMenuItem('Save As', 'File'); should probably
  964. #                be made prior to calling NameOK()
  965. #########################################################################
  966. # Example Calls
  967.     NameOk();                        # Generates a new file name with a call to 
  968.                                     # GetNewFileName(). The name will be based  
  969.                                     # on the application and the current time. 
  970.                                     # If a file exists with the generated name  
  971.                                     # it will be written over.
  972.     
  973.     NameOk(,n);                        # Same as above except, if a file exists 
  974.                                     # with the generated name it will not be   
  975.                                     # written over (The time will be appended 
  976.                                     # to the end of the name)
  977.     
  978.     NameOk('Working Document');        # Types 'Working Document' and types the    
  979.                                     # returnKey If a file exists with the same  
  980.                                     # name it will be written over.
  981.     
  982.     NameOk('Working Document', false);    # Same as above except, if a file exists 
  983.                                         # with the generated name it will not be  
  984.                                         # written over (The time will be 
  985.                                         # appended to the end of the name)
  986.  
  987.  
  988.  
  989. !NewPage
  990. #########################################################################
  991. #                        OpenDoc(namedoc,SelectOpen)
  992. #========================================================================
  993. # Author:        KTA
  994. # Description:    This routine will select 'Open' from the 'File' menu, type
  995. #                the string held in the nameDoc parameter, and
  996. #                then press the returnkey.  It will check to see that
  997. #                the frontmost window's title contains namedoc.  If not,
  998. #                it assumes that the wrong file opened.  It will not select
  999. #                'Open' if the SelectOpen parameter is 0.
  1000. # Parameters:    namedoc - string name of document to open
  1001. #                SelectOpen - 0 to disable selecting of the 'Open' menu item.
  1002. #                             1 to select 'Open' from the 'File' menu
  1003. #                             2 keyEq - 'o'
  1004. # Returns:        1 - Document opened OK
  1005. #                0 - Document not opened OK
  1006. # Assumptions:    Works with SF_Get, but don't have NameDoc be to long
  1007. #                of a string.
  1008. # Examples:        OpenDoc('Untit'); will select a document such as 'Untitled'.
  1009. #########################################################################
  1010. # Example Calls
  1011.     OpenDoc('DocName');        # Selects the 'Open' menu item from the 'File' menu,
  1012.                             # Types 'DocName' to Select the file to be opened.
  1013.                             # Types the ReturnKey, then output the name of the 
  1014.                             # first window with a zoom box and a growbox
  1015.  
  1016.     OpenDoc(LastSavedFile);        # Types the name of the last file that was
  1017.                                 # named with NameOK();
  1018.  
  1019. #########################################################################
  1020. #            SF_Navigate(PathList, TEToggle, FinalReturn)    
  1021. #========================================================================
  1022. # Author:        KTA
  1023. # Description:    Controls the navigation in Standard File. 
  1024. #                Assigns a global SF_OriginalPath to the current directory 
  1025. #                for return navigation.
  1026. #                Passes all parameters to SF_Type which performs actual navigation.
  1027. # Parameters:    PathList := List of directories beginning with the disk name.
  1028. #                TEToggle := Whether toggling from a text edit field is required 
  1029. #                            to navigate.
  1030. #                            1 - Toggle
  1031. #                            0 - No toggling required
  1032. #                FinalReturn := Whether to accept the final item in <Pathlist>
  1033. # Returns:        Pathlist
  1034. #########################################################################
  1035.  
  1036. #########################################################################
  1037. #                            SF_Type(PathList, TEToggle, FinalReturn )    
  1038. #========================================================================
  1039. # Author:        KTA
  1040. # Description:    Performs navigation in Standard File.
  1041. #                Selects the 'DeskTop' button. Then types each item in <PathList>
  1042. #                folled by a returnKey.
  1043. # Parameters:    PathList := List of directories beginning with the disk name.
  1044. #                TEToggle := Whether toggling from a text edit field is required 
  1045. #                            to navigate.
  1046. #                            1 - Toggle
  1047. #                            0 - No toggling required
  1048. #                FinalReturn := Whether to accept the final item in <Pathlist>
  1049. # Returns:        Nada
  1050. #########################################################################
  1051.  
  1052. !NewPage
  1053. #########################################################################
  1054. #            ReplaceExist( replaceFlag,NameDoc)    
  1055. #========================================================================
  1056. # Author:        KTA
  1057. # Description:    Handles the 'Replace existing?' dialog.
  1058. # Parameters:    ReplaceExist := Whether to Replace a document with the same name
  1059. #                or generate a unique name.
  1060. #                1 - Overwrite document with same name.
  1061. #                0 - Do not overwrite.  Generate unique name.
  1062. #                NameDoc := Name of file which already exists on disk.
  1063. # Returns:        NameDoc ( will be identical to the initial one if replaceFlag is set.
  1064. #########################################################################
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070. #########################################################################
  1071. #                            GetNewFileName(name)    
  1072. #========================================================================
  1073. # Author:        SL
  1074. # Description:    Gets a new file name by concatenating the app name and
  1075. #                the current time.
  1076. # Parameters:    name -    If this parameter is present, this routine will
  1077. #                        only pass back the time.  If this parameter is not
  1078. #                        present, then this routine will pass back a string
  1079. #                        consisting of the application name with the time
  1080. #                        appended to it.
  1081. # Returns:        newFileName - string name for new file name
  1082. #                    or just a time and Sec string
  1083. #########################################################################
  1084.  
  1085.  
  1086.  
  1087.  
  1088. #########################################################################
  1089. #                 Twitcher(appName)    
  1090. #========================================================================
  1091. # Author:         DM
  1092. # Description:    This task is intended to select apps from the Process List
  1093. #                menu in System 7.0.  Use LaunchTwitch to handle launching 
  1094. #                or twitching applications.
  1095. #                This routine selects apps from the Process List.
  1096. # Parameters:        appName - app to twitch to.
  1097. # Returns:            0 if twitching to appName fails
  1098. #                    TheCurrentApp - if twitching was successful
  1099. # Examples:            Twitcher("MacWrite 5.0");
  1100. # Assumptions:        None
  1101. #########################################################################
  1102. # Example Calls
  1103.     Twitcher("TeachText");        # Selects TeachText from the process list
  1104.  
  1105.  
  1106.  
  1107.  
  1108. !NewPage
  1109. #########################################################################
  1110. #                MiniLaunch(appTitle, LaunchApp, SetDir)
  1111. #========================================================================
  1112. # Author:        NJV - DMM
  1113. # Description:    This routine will launch an application on the target
  1114. #                machine(s).  The miniLauncher tool should be the running
  1115. #                application on the target machine(s).  This routine will
  1116. #                type the input parameter appTitle to the target machine
  1117. #                and then type the return key (which is how an application
  1118. #                is launched using miniLauncher.)  The application to be
  1119. #                launched must reside in a folder beneath the miniLauncher
  1120. #                tool in the directory hierarchy. For more information on
  1121. #                the miniLauncher tool, see the read-me that accompanies
  1122. #                the tool.  
  1123. #                MiniLauncher can also open or print documents.  See the
  1124. #                LaunchApp parameter description below for more details.
  1125. #
  1126. # Parameters:    appTitle -    title of the application or document to be launched.
  1127. #                            The title does not have to be complete.  The MiniLauncher
  1128. #                            tool will launch the first application it finds
  1129. #                            starting with the string appTitle.  If LaunchApp
  1130. #                            parameter is not 1, then appTitle will hold the
  1131. #                            document name to be opened or printed.
  1132. #                LaunchApp - 1 to launch application
  1133. #                            0 to launch application via a document
  1134. #                            -1 to print a document (launch app and print)
  1135. #                SetDir    -    1 to set the default directory to that of the
  1136. #                                application
  1137. #                            0 to bypass setting of default directory (will
  1138. #                                end up being MiniLauncher's directory).
  1139. #
  1140. # Returns:        1 - Launched OK
  1141. #                0 - Couldn't launch application (usually due to lack of 
  1142. #                        enough memory on the target machine).
  1143. #
  1144. # Examples:        MiniLaunch('Word');
  1145. #########################################################################
  1146. # Example Calls
  1147.     MiniLaunch("TeachText");    # Launches TeachText on the target machine
  1148.                                 # and sets current working directory to
  1149.                                 # that of application
  1150.                                 
  1151.     MiniLaunch("TeachText Doc",0);
  1152.                                 # Launches TeachText via the "TeachText Doc"
  1153.                                 # document (TeachText is responsible for
  1154.                                 # setting current working directory
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170. !NewPage
  1171. #########################################################################
  1172. #            LaunchTwitch(AppName, AliasDir, LaunchApp, SetDir)
  1173. #========================================================================
  1174. # Author:            KTA
  1175. # Description:        This routine determines whether the Operating system is 
  1176. #                    6.0x or 7.0x and launches the application accordingly.  
  1177. #                    6.0x -  Will check the Apple menu to see if the App is 
  1178. #                    currently running and select it if it is. If it is not running
  1179. #                    it will select Mini from the Apple menu and call MiniLaunch(AppName);
  1180. #                    7.0x -  Will check the ProcessList to see if the App is 
  1181. #                    currently running and select it if it is.  if it is not it will
  1182. #                    Select the Apple from the Apple Menu, or the <AliasDir> and then type
  1183. #                    the <AppName> and select the Open menuItem.
  1184. # Parameters:        AppName - Application to be launched/Twitched
  1185. #                    AliasDir -  Folder in the Apple menu that contains <AppName>.
  1186. #                    LaunchApp - 0    Select from Process list - Do not launch the App.
  1187. #                                1    Select from Process list or launch the App if 
  1188. #                                    necessary.
  1189. # Returns:            0 - App did not launch
  1190. #                    1 - App launched fine
  1191. #                    2 - App launched with minimum memory
  1192. # Examples:            LaunchTwitch('MacWrite', "#CoreAliases");
  1193. #                    LaunchTwitch('MacWrite Doc',"#CoreAliases",0);
  1194. # Assumptions:        7.0x -  That the Application (or Alias) is resident in the 
  1195. #                    Apple Menu or the <AliasDir> which contains <AppName> is.
  1196. #########################################################################
  1197. # Example Calls
  1198.     LaunchTwitch("TeachText","Aliases");    # if 6.0.x, selects MiniLauncher
  1199.                                             # from process list and types
  1200.                                             # "TeachText" and hits <return>
  1201.                                             
  1202.                                             # if 7.0.x, selects "Aliases"
  1203.                                             # from Apple Menu, types
  1204.                                             # "TeachText" to select TeachText
  1205.                                             # alias and then selects "Open"
  1206.  
  1207.  
  1208. #########################################################################
  1209. #                PatchLaunchTwitcher()
  1210. #========================================================================
  1211. # Author:        KTA
  1212. # Description:    
  1213. # Parameters:    
  1214. # Returns:        
  1215. # Examples:        
  1216. # Assumptions:    
  1217. #########################################################################
  1218.  
  1219. #    write your own launching mechanisms - set global patchLaunchTwich to true
  1220.  
  1221.  
  1222.  
  1223.  
  1224. !NewPage
  1225. #String Tasks
  1226. #########################################################################
  1227. #                             IsSubString(str1, str2)
  1228. #=======================================================================
  1229. # Author:              SL
  1230. # Description:        Checks to see if str1 is in str2.
  1231. # Parameters:        str1    :=    Substring to be searched for.
  1232. #                    str2    :=    String.
  1233. # Returns:            0        :=    str1 is not in str2.
  1234. #                    1        :=    str1 is in str2.
  1235. #########################################################################
  1236. # Example Calls
  1237.     reply := IsSubString("llo","Hello");    # reply = true
  1238.     reply := IsSubString("Hello","llo");    # reply = false
  1239.  
  1240. #########################################################################
  1241. #                         FindPos(char, str, startPos)
  1242. #=======================================================================
  1243. # Author:          SL
  1244. # Description:    Finds the first occurence of char in str starting
  1245. #                from startPos.
  1246. # Parameters:    char    :=    A character to be searched for.
  1247. #                str        :=     String.
  1248. #                startPos:=    Starting position to be searched.
  1249. # Returns:        0        :=    Char is not in str starting from
  1250. #                            startPos.
  1251. #                pos        :=     Char position of its first occurence
  1252. #                            starting from startPos.
  1253. #########################################################################
  1254. # Example Calls
  1255.     thePosition := FindPos("o","Foobar");    # thePosition = 2
  1256.     thePosition := FindPos("o","Fubar");    # thePosition = 0
  1257.  
  1258. #########################################################################
  1259. #                         Substring(String,StartChar,NumChar)
  1260. #=======================================================================
  1261. # Author:          PF 
  1262. # Description:    returns the first NumChar characters of the passed String
  1263. #                starting at StartChar.
  1264. # Parameters:    String - String to use
  1265. #                StartChar - Character to start making substring from
  1266. #                NumChar - Integer number of characters to return
  1267. # Returns:        string
  1268. # Assumptions:    none
  1269. ##########################################################################
  1270. # Example Calls
  1271.     theStr := Substring("Foobar","b",2);    # theStr = "ba"
  1272.     theStr := Substring("Foobar","F",3);    # theStr = "Foo"
  1273.  
  1274. # Drawing/Tool Tasks    
  1275. ########################################################################
  1276. #                     DrawShapeFrame(specifier := 1,ltrb)                        
  1277. #=======================================================================
  1278. # Author:         DMM                        
  1279. # Description:    Click drags a rectangular frame in the specified window.                                            
  1280. # Parameters:    specifier    window to draw in; defaults to ordinality 1            
  1281. #                ltrb         {"random"} or {l,t,r,b} of rect to draw 
  1282. #                inset         defines the drawing area relative to the 
  1283. #                            window rectangle
  1284. # Returns:        nada
  1285. #########################################################################
  1286. !NewPage
  1287. #########################################################################
  1288. #            SelToolFromWindow(the_tool,specifier,WhichToolStr)
  1289. #========================================================================
  1290. # Author:        DMM
  1291. # Description:    This task selects tools that are embedded in document
  1292. #                windows
  1293. # Parameters:    the_tool -    tool position in palette counting left to right,
  1294. #                        top to bottom
  1295. #                specifier - ordinality of doc window containing tools
  1296. #                WhichToolStr - String name of tool
  1297. # Returns:      1 - selected tool
  1298. #                0 - couldn't select tool
  1299. # Assumptions:    Tools are selected from the front window, tool rectangles
  1300. #                are the same size
  1301. #                as a window.
  1302. # Examples:        SelToolFromWindow(1,2);
  1303. #########################################################################
  1304.  
  1305.  
  1306. #########################################################################
  1307. #            SelToolFromPallette(the_tool,specifier,WhichToolStr)
  1308. #========================================================================
  1309. # Author:        DMM
  1310. # Description:        This task selects tools from palettes that VU sees as
  1311. #                    separate windows
  1312. # Parameters:        the_tool -    tool position in palette counting left to right,
  1313. #                                top to bottom
  1314. #                    specifier -    holds title or ordinality of palette window
  1315. #                    WhichToolStr - String name of tool
  1316. # Return Values:    1 - selected tool
  1317. #                    0 - couldn't select tool
  1318. # Assumptions:        Tool rectangles are the same size, VU can see the palette
  1319. #                    as a window (tear off menus are torn off).
  1320. # Examples:            SelToolFromPallette(1);
  1321. #########################################################################
  1322.  
  1323.  
  1324. #########################################################################
  1325. #                            DoDraw()
  1326. #========================================================================
  1327. # Author:        DM (x41220)
  1328. # Description:    Selects drawing tool and uses it.
  1329. # Parameters:    PaletteType - Type of palette
  1330. #                    1 - Palette is a part of document window
  1331. #                    2 - Palette is it's own window
  1332. # Returns:        Nothing
  1333. # Examples:        DoDraw();
  1334. # Assumptions:    That the application sets up the appropriate globals
  1335. #                ( see SelToolFromWindow or SelToolFromPalette 
  1336. #                Global ToolMultiplier,ToolList,Inset,Specifier,ToolRect,
  1337. #                ToolsAcross,ToolsDown,HeaderHeight)
  1338. #                if SelToolFromWindow() - HeaderHeight is not defined
  1339. #                if SelToolFromPalette() - ToolRect is not defined
  1340. # Applications:        
  1341. #########################################################################
  1342.  
  1343.  
  1344.  
  1345. !NewPage
  1346. #########################################################################
  1347. #                    DoText (NextLineKey, Specifier, inset)
  1348. #========================================================================
  1349. # Author:        ML
  1350. #    
  1351. # Description:    This routine will choose a random font size (from global fontSizeList) 
  1352. #                and multiple random font styles (from global fontStyleList) for each of 
  1353. #                the fonts in the global fontlist. The text defined in the global TextStr,
  1354. #                followed by the chosen font, size and styles will then be typed.  
  1355. #                It will then either type the key required to move to the next line, 
  1356. #                or move to a random position and click. 
  1357. #                        
  1358. # Parameters:    NextLineKey - How to move to the next line
  1359. #                              0 Pointer will randomly move and click
  1360. #                              1 Return Key - DEFAULT
  1361. #                              2 Enter Key
  1362. #                              3 Down Arrow Key
  1363. #                              4 Tab Key
  1364. #                Specifier - Use if 0 is passed to NextLineKey.  Holds title or ordinality of
  1365. #                            window to randomly move and click in.  Default is "Untitled".
  1366. #                Inset    -   Use if 0 is passed to NextLineKey.  Inset from window rect for 
  1367. #                            MoveRelativeToWindow.  Default is {30,30,30,30}.                 
  1368. #    
  1369. # Returns:      none
  1370. #    
  1371. # Examples:        DoText (0)
  1372. #                
  1373. # Assumptions:    This routine cannot be used if names, sizes or styles are chosen via dialog box
  1374. #                (i.e. Excel).    
  1375. #    
  1376. #                Your script places the cursor in the starting position where you want the first
  1377. #                text string to be typed before you call DoText().  If you are passing 0 to 
  1378. #                NextLineKey (you want pointer to randomly move and click), you script must choose
  1379. #                the text tool, close all tool palette windows, and click in the starting position
  1380. #                where you want the first TextStr to be typed before you call DoText().
  1381. #    
  1382. #                Some apps (i.e. Pagemaker and Works) use the menu item “Normal” instead of “Plain”
  1383. #                in describing font style.  Is these cases, you must replace the correct 
  1384. #                menuitem name with a call to ReplaceItem(). for example:
  1385. #                Global FontStyleList := Replaceitem('Plain', 'Normal', FontStyleList);
  1386. #########################################################################
  1387.  
  1388.  
  1389.  
  1390.  
  1391. !NewPage
  1392. #Misc.Tasks
  1393. ########################################################################
  1394. #                        PageSetup( WhichDevice )
  1395. #=======================================================================
  1396. # Author:             KTA
  1397. # Description:        For PageSetup routines
  1398. # Parameters:        Nada
  1399. # Returns:            None
  1400. ########################################################################
  1401. # Example Call
  1402.     PageSetup();    # Selects "Page Setup" from File menu and hits <return>
  1403.  
  1404. ########################################################################
  1405. #                        Print()
  1406. #=======================================================================
  1407. # Author:             KTA
  1408. # Description:        For Print routines
  1409. # Parameters:        Nada
  1410. # Returns:            None
  1411. ########################################################################
  1412.  
  1413.  
  1414.  
  1415. #########################################################################
  1416. #                            IsNumber(whatAmI)
  1417. #========================================================================
  1418. # Author:            NJV
  1419. # Description:        This routine determine whether the input parameter is
  1420. #                    a number or not.  This could be done directly in-line,
  1421. #                    but to avoid Developer's having to modify their code,
  1422. #                    I updated this routine so that scripts will still work
  1423. #                    properly unmodified.
  1424. # Parameters:        whatAmI - item to check
  1425. # Returns:            true - the parameter is a number
  1426. #                    false - the parameter is not a number
  1427. # Examples:            IsNumber("Hello");
  1428. # Assumptions:        None
  1429. #########################################################################
  1430. # Example Calls
  1431.     IsNumber(2);            # Returns True. The value is a number
  1432.     IsNumber('Hello');        # Returns False. The string is not a number
  1433.  
  1434. #########################################################################
  1435. #                        PtInRect(thePoint,theRect)
  1436. #========================================================================
  1437. # Author:            NJV
  1438. # Description:        This routine determines whether or not thePoint 
  1439. #                    is contained within theRect (including borders). 
  1440. # Parameters:        thePoint - a list of two integers
  1441. #                    theRect - holds the coordinates of the rectangle.
  1442. # Returns:            true - point lies in the rectangle.
  1443. #                    false - point does NOT lie in the rectangle.
  1444. # Examples:            isIt := PtInRect(thePoint,theRect).
  1445. # Assumptions:        None
  1446. #########################################################################
  1447. # Example Calls
  1448.     PointIsInRect := PtInRect({2,2}, {0,0,20,20});        # Returns True
  1449.     PointIsInRect := PtInRect({22,22}, {0,0,20,20});    # Returns False
  1450.  
  1451. !NewPage
  1452. #########################################################################
  1453. #                         CenterofScreenClick()
  1454. #=======================================================================
  1455. # Author:          KTA
  1456. # Description:    Clicks in the center of main screen
  1457. # Parameters:    none
  1458. # Returns:        Nada
  1459. #########################################################################
  1460. # Example Call
  1461.     CenterOfScreenClick();    # Clicks in center of screen with Menu bar
  1462.     
  1463. #########################################################################
  1464. #                          RemoveItem(Item,List)
  1465. #========================================================================
  1466. # Author:        KA & JM
  1467. # Description:    This routine was designed to remove items from lists.  
  1468. # Parameters:    Item - Item to be removed from the list
  1469. #                List - any list
  1470. # Returns:        Newlist := if Item is removed from List
  1471. #                0 := if Item is not contained in List
  1472. #########################################################################
  1473.  
  1474.  
  1475.  
  1476. #########################################################################
  1477. #             ReplaceItem(ItemtoBeReplaced, ReplaceItem, List)
  1478. #========================================================================
  1479. # Author:        KA 
  1480. # Description:    This routine was designed to replace items in lists.  
  1481. # Parameters:    ItemtoBeReplaced - Item to be replaced from the list
  1482. #                ReplaceItem - Item which will now be a part of the list
  1483. #                List - any list
  1484. # Returns:        Newlist := if ItemtoBeReplaced is replaced from List
  1485. #                0 := if ItemtoBeReplaced is not contained in List
  1486. #########################################################################
  1487.  
  1488.  
  1489.  
  1490.  
  1491. #########################################################################
  1492. #                             Timer(timeParam)
  1493. #=======================================================================
  1494. # Author:              DM
  1495. # Description:        Calculates the time between two time descriptors 
  1496. # Parameters:        timeParam - Specifier - what to return
  1497. #                    1 - return ({"{theHour}:{theSec}",theHour,theSec});
  1498. #                    2 - return (("{theMonth}/{theDay}/{theYear}"))
  1499. #                    3 - return (theTime) - full descriptor
  1500. #                    4 - CurrentTime - formatted
  1501. # Example:            Timer(1);
  1502. #########################################################################
  1503.  
  1504.  
  1505.  
  1506. !NewPage
  1507. #########################################################################
  1508. #                             ETime(time1, time2)
  1509. #=======================================================================
  1510. # Author:              DM
  1511. # Description:        Calculates the time between two time descriptors 
  1512. # Parameters:        time1 - initial time
  1513. #                    time2 - end time
  1514. # Returns:            "{eh}:{em}:{es}" - Difference between the two
  1515. # Example:            ETime(time1, time2);
  1516. #########################################################################
  1517.  
  1518.  
  1519. #########################################################################
  1520. #                             DoSpecialTest(WhichTest)
  1521. #=======================================================================
  1522. # Author:              KTA
  1523. # Description:        Hook for any special tests all the Standard QuickLooks 
  1524. #                    Call this task 3 times. 
  1525. # Parameters:        WhichTest - Scriptor defined tests.
  1526. # Returns:            Whatever you want.
  1527. # Example:            DoSpecialTest(1);
  1528. #=======================================================================
  1529. # History:
  1530. # KTA     9/04/90        Created
  1531. #########################################################################
  1532.  
  1533.  
  1534. #########################################################################
  1535. #                Scrapbook(requestElement,ccpFlag,pasteFlag)
  1536. #========================================================================
  1537. # Author:        KTA
  1538. # Description:    This routine will select the scrapbook, scroll to the
  1539. #                designated requestElement position, select Cut, Copy, Paste,
  1540. #                or Clear from the Edit menu, close the scrapbook if under System
  1541. #                6.0.x, and then select Paste if the pasteFlag parameter is 1.
  1542. # Parameters:    requestElement - the element in the scrapbook to scroll to
  1543. #                ccpFlag -    1 for copy
  1544. #                            2 for cut
  1545. #                            3 for paste
  1546. #                            4 for clear
  1547. #                pasteFlag - 1 to paste after closing Scrapbook
  1548. #                            0 not to paste after closing Scrapbook
  1549. # Returns:        0 - Couldn't complete operation
  1550. #                element - Scrapbook element that operation took place on
  1551. # Examples:        Scrapbook(2) will scroll the horizontal bar to the
  1552. #                second entry and then copy, close and paste.
  1553. # Assumptions:    That the scrollbars are present. That the string
  1554. #                'Scrapbook' appear somewhere in the name
  1555. #########################################################################
  1556. # Example Call
  1557.     Scrapbook(1,1);                # Matches and selects the Scrapbook from the 
  1558.                                 # Apple menu, scrolls to the first item,  
  1559.                                 # selects 'Copy' from the 'Edit' menu, closes 
  1560.                                 # the Scrapbook, by way of the close box, then 
  1561.                                 # selects 'Paste' from the 'Edit' menu.
  1562.                                     
  1563.     Scrapbook(2,2,0);            # Matches and selects the Scrapbook from the 
  1564.                                 # Apple menu, scrolls to the second item,  
  1565.                                 # selects 'Cut' from the 'Edit' menu, and closes 
  1566.                                 # the Scrapbook by way of the close box.
  1567. !NewPage                            
  1568. #########################################################################
  1569. #                         Quit(OverWrite, DocName)
  1570. #=======================================================================
  1571. # Author:          KTA
  1572. # Description:    Will turn off the Application Verification scheme, Select
  1573. #                the Quit menu item, check whether or not to save changes,
  1574. #                then reset the App verification scheme to its previous state.
  1575. # Parameters:    OverWrite    1    - Save changes.
  1576. #                            0    - Don't save changes.
  1577. #                DocName        -    The string that will be used to save the document
  1578. #                HowQuit        1    - Select "Quit" from File Menu
  1579. #                            2    - Type Cmd-Q to quit
  1580. # Returns:        Nada
  1581. #########################################################################
  1582. # Example Calls
  1583.     Quit();                # Selects "Quit" from the File menu, selects "Yes"
  1584.                         # to any "Save Changes" dialog, and selects "Yes" to
  1585.                         # any "Replace existing" dialog
  1586.  
  1587.     Quit(0);            # Selects "Quit" from the File menu and selects "No"
  1588.                         # to any "Save Changes" dialog.
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.